--
-- Author: yawei.zhu
-- Date: 2018-12-15 15:10:30
--
-- PvpChallengePlayerRender
--
local HeadRender = require("app.widget.renders.HeadRender")

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.PvpChallengePlayerNode))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize(self._ui.Panel:getContentSize())

    self._head = HeadRender.create(self._ui.head, 3)
end

function ClassRef:refresh()
    if not self._data then return end
    local baseInfo = self._data.baseInfo

    if self._data.IsReady then
        self._ui.icon_ok:setVisible(true)
    else
        self._ui.icon_ok:setVisible(false)
    end

    self._ui.icon:setVisible(false)
    self._ui.name:setString(baseInfo.name)
    self._head:setData(baseInfo)
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
